'use strict';

// eslint-disable-next-line no-unused-vars
module.exports = options => {
  return async (ctx, next) => {
    const url = ctx.request.url;
    // console.log('url:', url);
    const session = ctx.session.user;
    console.log(session);
    if (!session && !options.exclude.includes(url.split('?')[0])) {
      ctx.body = {
        status: 10001,
        errMsg: '用户未登录',
      };
    } else {
      await next();
    }
  };
};
